public class test4 {
    class Solution {
        public int numDistinct(String s, String t) {
            char[] ch1 = s.toCharArray();
            char[] ch2 = t.toCharArray();
            int[][] dp = new int[ch1.length+1][ch2.length+1];//可能性

            //初始化【必不可少！】
            for(int i = 0;i<ch1.length+1;i++){
                dp[i][0] = 1;
            }

            for(int i = 1;i<ch1.length+1;i++){
                for(int j = 1;j<ch2.length+1;j++){
                    if(ch1[i-1]==ch2[j-1]){
                        //取或不取
                        //不取相当于删了
                        dp[i][j] = dp[i-1][j-1]+dp[i-1][j];
                    }else{
                        //不取
                        dp[i][j] = dp[i-1][j];
                    }
                }
            }
            return dp[ch1.length][ch2.length];
        }
    }
}
